package com.example.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.demo.domain.consignee;
import com.example.demo.servise.impl.ibookserverimpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//@RestController
@RequestMapping("/books")
public class BookContoller {
    @Autowired
    private ibookserverimpl ibk;
//    查全部
    @GetMapping
    public List <consignee>getAll(){
        return ibk.list();
    }
//    保存
    @PostMapping
    public Boolean save(@RequestBody consignee con ){
        return ibk.save(con);
    }
//    更新
    @PutMapping()
    public Boolean update(@RequestBody consignee con ){
        return ibk.updateById(con);
    }
//    删除
    @DeleteMapping ("{id}")
    public Boolean delete(@PathVariable Integer id ){
        return ibk.removeById(id);
    }
//    查单个
    @GetMapping("{id}")
    public consignee getById(@PathVariable Integer id){
        return ibk.getById(id);
    }
//    查询分页
    @GetMapping("{currentPage}/{pageSize}")
    public IPage<consignee>getPage(@PathVariable int currentPage, @PathVariable int pageSize){
        return ibk.getPage(currentPage,pageSize);
    }
}
